{template "header.html"}
 <script type="text/javascript" src="http://api.map.baidu.com/api?key=&v=1.1&services=true"></script>
{template "nav.html"}
<style>

    input {
        border:1px;
        border-color:gray;
    }
    .inputtd{
    	width: 480px;
    }
    .map-bottom {
        background-image:url({HOME_THEME_PATH}images/contactus/map_bottom.png);
        background-repeat:repeat-x;
        width:100%;
        height:28px;
        
    }
	.td_det{
		font-size:18px;
		color:#555;
	}
	.td_txt{
		width:444px;
		height:43px;
        font-size:18px;
        padding-left:20px;
		border: 1px solid #aaa;
	}
	.td_textarea{
		resize:none;
		width:626px;
		height:163px;
		border-color:rgb(192,192,192);
		border-radius:4px; 
		font-size:18px; 
		padding-left:20px;
		padding-top:12px;
	}
	.td_txt_warning{
		width:444px;
		height:43px;
        font-size:18px;
        padding-left:20px;
		border: 1px solid #f00;
	}
	.war_txt_show{
		color: red;
		font-size:14px;
		display: block;
	}
	.war_txt_hide{
		color: red;
		font-size:14px;
		display: none;
	}
    .btn{
        background-color:transparent;
		border:0px;
		width:132px;height:48px;
		background-size:cover;
		background-image:url({HOME_THEME_PATH}images/contactus/btn1.png);
     	cursor:pointer;
     	color:white;
	}
    .btn:active{
        background-color:transparent;     
		border:0px;
		width:132px;height:48px;
		background-size:cover;
		background-image:url({HOME_THEME_PATH}images/contactus/btn2.png);
	}
</style>
<img src="{HOME_THEME_PATH}images/contactus/map.png" style="width:100%;height:auto;"/>
<div class="map-bottom">
</div>
<div style="width:100%;padding-top:5px;color:black;"></div>
	<div style="width:915px;margin:0 auto;">
	<div style="margin:0 auto;margin-top:114px;height:20px;width:400px;padding-bottom:40px;">
		<a style="font-size:32px;">联系我们&nbsp;&nbsp;</a><a style="color:#555;font-size:32px;padding-bottom:78px;">·&nbsp;&nbsp;CONTACT US</a>
	</div>
	<div style="margin-top:79px;padding-bottom:40px;">
		<table>
			<tr>
				<td>				
				<table style="width:350px;height: 240px;margin-top: -240px;" cellspacing="10">
					<tr>
						<td style="font-size: 23px;"><div>上海汕游网络科技有限公司</div></td>
					</tr>
					<tr>
						<td><span>&nbsp;&nbsp;&nbsp;</span></td>
					</tr>
					<tr>
						<td class="td_det">
							<span style="float: left;">地址：&nbsp;&nbsp;</span>
							<span style="float: left;width: 280px;display: inline-block;">上海市浦东新区东三里桥路1018号上海数字产业园B座204</span>
						</td>
					</tr>	
					<tr>
						<td class="td_det">电话：&nbsp;&nbsp;4000215098</td>
					</tr>	
					<tr>
						<td class="td_det">网址：&nbsp;&nbsp;www.shanyou666.com</td>
					</tr>	
					<tr>
						<td class="td_det">邮编：&nbsp;&nbsp;200125</td>
					</tr>	
					<tr>
						<td class="td_det">Email:&nbsp;&nbsp;shanyouwangluo2015@163.com</td>
					</tr>
				</table>
				</td>
				<td>	
					<div style="width: 78px"></div>
				</td>
				<td>
                    <form id="contusf">	
				<table style="height:520px;" cellspacing="21">
					<tr>
						<td class='inputtd'><input name="name" id="name" class="td_txt" type="text" placeholder="姓名(必填)"/></td><td><span class="war_txt_hide" id="na_wa_txt">昵称不可以为空</span></td>
					</tr>
					<tr>
						<td class='inputtd'><input name="phone" id="mobile" class="td_txt" type="text" placeholder="电话(必填)"/></td><td><span class="war_txt_hide" id="mo_wa_txt">请输入有效的手机号码</span>
					</tr>	
					<tr>
						<td class='inputtd'><input name="email" id="email" class="td_txt" type="text" placeholder="Email(选填)"/></td><td><span class="war_txt_hide" id="em_wa_txt">邮箱地址格式错误</span></td>	
					</tr>
					<tr>
						<td colspan="2"><textarea name="remark" id="remark" class='td_textarea' placeholder="备注:(选填200字以内)" style=""></textarea></td>
					</tr>
					<tr>
						<td>
                        <div>
                            <input type="button" class="btn" value="" onclick="feedback()"/>
                        </div>
                        </td>
					</tr>
				</table>
				</form>
		
				</td>
				
			</tr>
		</table>
	</div>
	</div>
<!--百度地图容器-->

<script>
	
	function changeColor(){
		var mobile = $("#mobile");
		var name = $("#name");
		var email = $("#email");
		var tb1 = $(mobile).parent().nextAll('td').eq(0).find('span').eq(0);
		var tb2 = $(name).parent().nextAll('td').eq(0).find('span').eq(0);
		var tb3 = $(email).parent().nextAll('td').eq(0).find('span').eq(0);
		var tag1 = 1;
		var tag2 = 1;
		var tag3 = 1;
		
		
		if(!(/^1(3|4|5|7|8)\d{9}$/.test(mobile.val()))){ 
			$(mobile).removeClass( "td_txt" ).addClass("td_txt_warning");
			$(tb1).removeClass("war_txt_hide").addClass("war_txt_show");
			tag = 0;
		}
		if( name.val().length == 0 ){
			$(name).removeClass( "td_txt" ).addClass("td_txt_warning");
			$(tb2).removeClass("war_txt_hide").addClass("war_txt_show");
			tag2 = 0;
		}
		if( email.val().length > 0 ){
			if( !isEmail(email.val() ) ){
				$(email).removeClass( "td_txt" ).addClass("td_txt_warning");
				$(tb3).removeClass("war_txt_hide").addClass("war_txt_show");
				tag3 = 0;
			}
		}else{
			//$(email).removeClass( "td_txt" ).addClass("td_txt_warning");
			//$(tb3).html("邮箱地址未填写");
			//$(tb3).removeClass("war_txt_hide").addClass("war_txt_show");
			//tag3 = 0;
		}
		
		if( tag1 && tag2 )
		{
			return true;
		}
		return false;
	}
	
	function checkform() {
		return changeColor();
	}
	
	function feedback()
	{
	    if (checkform()){
	        var mobile = $("#mobile").val();
	        var name = $("#name").val();
	        var email = $("#email").val();
	        var remark = $("#remark").val();
	        $.ajax({
	            type: 'post',
	            dataType: "json",
	            url: "/index.php?c=form&mid=liuyan",
	            data: { 
	            	'data[title]' : name ,
	            	'data[phonenum]' : mobile ,
	            	'data[email]' : email ,
	            	'data[content]' : remark 
	            },
	            success: function (data) {
	                if(data){
	                    alert(data.code);
	                    if (data.code.indexOf("成功") > -1){
                        	location.reload()
	                    }
	                }
	            },
	            crossDomain: false
	        })
	    }
	}
	
	$(function(){  
		 $("input").focus(function(){  
		  	$(this).removeClass( "td_txt_warning" ).addClass("td_txt");
			var tb = $(this).parent().nextAll('td').eq(0).find('span').eq(0);
			$(tb).removeClass("war_txt_show").addClass("war_txt_hide");
		 }).blur(function(){  
		   	changeColor();
		 });  
    });  
	
	
	
	function isEmail(str){
    	var reg = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/;
       	return reg.test(str);
   	}
</script>
<script type="text/javascript">
    //创建和初始化地图函数：
    function initMap(){
        createMap();//创建地图
        setMapEvent();//设置地图事件
        addMapControl();//向地图添加控件
        addMarker();//向地图中添加marker
    }
    
    //创建地图函数：
    function createMap(){
        var map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图
        var point = new BMap.Point(121.524413,31.198044);//定义一个中心点坐标
        map.centerAndZoom(point,17);//设定地图的中心点和坐标并将地图显示在地图容器中
        window.map = map;//将map变量存储在全局
    }
    
    //地图事件设置函数：
    function setMapEvent(){
        map.enableDragging();//启用地图拖拽事件，默认启用(可不写)
        map.enableScrollWheelZoom();//启用地图滚轮放大缩小
        map.enableDoubleClickZoom();//启用鼠标双击放大，默认启用(可不写)
        map.enableKeyboard();//启用键盘上下左右键移动地图
    }
    
    //地图控件添加函数：
    function addMapControl(){
        //向地图中添加缩放控件
	var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE});
	map.addControl(ctrl_nav);
        //向地图中添加缩略图控件
	var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1});
	map.addControl(ctrl_ove);
        //向地图中添加比例尺控件
	var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
	map.addControl(ctrl_sca);
    }
    
    //标注点数组
    var markerArr = [{title:"上海汕游网络科技有限公司",content:"振华企业广场",point:"121.524709|31.198337",isOpen:0,icon:{w:21,h:21,l:0,t:0,x:6,lb:5}}
		 ];
    //创建marker
    function addMarker(){
        for(var i=0;i<markerArr.length;i++){
            var json = markerArr[i];
            var p0 = json.point.split("|")[0];
            var p1 = json.point.split("|")[1];
            var point = new BMap.Point(p0,p1);
			var iconImg = createIcon(json.icon);
            var marker = new BMap.Marker(point,{icon:iconImg});
			var iw = createInfoWindow(i);
			var label = new BMap.Label(json.title, { "offset": new BMap.Size(json.icon.lb - json.icon.x - 10, -50) });
			marker.setLabel(label);
            map.addOverlay(marker);
            label.setStyle({
                        borderColor:"#808080",
                        color:"#333",
                        cursor:"pointer"
            });
			
			(function(){
				var index = i;
				var _iw = createInfoWindow(i);
				var _marker = marker;
				_marker.addEventListener("click",function(){
				    this.openInfoWindow(_iw);
			    });
			    _iw.addEventListener("open",function(){
				    _marker.getLabel().hide();
			    })
			    _iw.addEventListener("close",function(){
				    _marker.getLabel().show();
			    })
				label.addEventListener("click",function(){
				    _marker.openInfoWindow(_iw);
			    })
				if(!!json.isOpen){
					label.hide();
					_marker.openInfoWindow(_iw);
				}
			})()
        }
    }
    //创建InfoWindow
    function createInfoWindow(i){
        var json = markerArr[i];
        var iw = new BMap.InfoWindow("<b class='iw_poi_title' title='" + json.title + "'>" + json.title + "</b><div class='iw_poi_content'>"+json.content+"</div>");
        return iw;
    }
    //创建一个Icon
    function createIcon(json){

        var icon = new BMap.Icon("../../static/app/img/contactus/dticon2.png", new BMap.Size(json.w, json.h), { imageOffset: new BMap.Size(-json.l, -json.t), infoWindowOffset: new BMap.Size(json.lb + 5, 1), offset: new BMap.Size(json.x, json.h) })
        return icon;
    }
    
    initMap();//创建和初始化地图
</script>

{template "footer.html"}